import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);
let store = new Vuex.Store({
    // 1. state
    state:{
        test: ''
    },

    // 2. getters
    getters:{
        getTestFn(state) {
            return state.test
        },

    },
    // 3. actions
    // 通常跟api接口打交道
    actions:{

        setCityName({commit,state}, name){
            commit("setTest", name);
        }
    },
    // 4. mutations
    mutations:{
        setTest(state, value) {
            state.test = value
        },

    }
});

export default store;